package com.stox.shared.util;

public class StringUtil {

	public static boolean hasText(final String text) {
		return (null != text) && (0 != text.trim().length());
	}

	public static String splitCamelCase(final String s) {
		return s.replaceAll(String.format("%s|%s|%s", "(?<=[A-Z])(?=[A-Z][a-z])", "(?<=[^A-Z])(?=[A-Z])", "(?<=[A-Za-z])(?=[^A-Za-z])"), " ");
	}

	public static String stringValueOf(double value) {
		String text = "";
		if (value >= 1000000000) {
			text = "B";
			value /= 1000000000;
		} else if (value >= 1000000) {
			text = "M";
			value /= 1000000;
		} else if (value >= 1000) {
			text = "K";
			value /= 1000;
		}
		return String.valueOf(Constant.numberFormat.format(value) + text);
	}


}
